package app.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import app.config.Config;
import app.domain.FixOrderStatus;
import app.domain.Result;
import app.service.FixOrderStatusService;

@Controller
@RequestMapping("OrderStatus")
public class FixOrderStatusController {
	@Autowired
	private FixOrderStatusService  fixOrderStatusService;
	@RequestMapping("/listAll")
    @ResponseBody
    public Result listAll(){
 	   Result result=new Result(Config.SUCCESS_CODE,"");
 	   try{
 		   List<FixOrderStatus> list=fixOrderStatusService.listAll();
 		   result.setRow(list);
 	   }
 	   catch(Exception e){
 		   e.printStackTrace();
 		   result.setCode(Config.FAIL_CODE);
 		   return result;
 	   }
 	   return result;
    }
	
	@RequestMapping("/list")
    @ResponseBody
    public Result listByOrderId(int fixOrderId){
 	   Result result=new Result(Config.SUCCESS_CODE,"");
 	   try{
 		   List<FixOrderStatus> list=fixOrderStatusService.getStatusInfo(fixOrderId);
 		   result.setRow(list);
 	   }
 	   catch(Exception e){
 		   e.printStackTrace();
 		   result.setCode(Config.FAIL_CODE);
 		   return result;
 	   }
 	   return result;
    }
	
	@RequestMapping("/listByAccount")
    @ResponseBody
    public Result listAll(int accountId){
 	   Result result=new Result(Config.SUCCESS_CODE,"");
 	   try{
 		   List<FixOrderStatus> list=fixOrderStatusService.getByAccount(accountId);
 		   result.setRow(list);
 	   }
 	   catch(Exception e){
 		   e.printStackTrace();
 		   result.setCode(Config.FAIL_CODE);
 		   return result;
 	   }
 	   return result;
    }
}
